﻿/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
#region Using directives

using System;
using System.Text;
using ELE.Common.Util;

#endregion

namespace ELE.EnterpriseLibrary.Naming.Configuration
{
  /// <summary>
  /// A component configuration definition class
  /// </summary>
	public class ComponentConfiguration : GenericConfiguration
  {
    /// <summary>
    /// Tag name for the component root node
    /// </summary>
    public const string TAGNAME_COMPONENT = "component";
    /// <summary>
    /// Tag name in the config file to define mathods to be called in the component at init time
    /// </summary>
    public const string TAGNAME_METHODS = "methods";
    /// <summary>
    /// Tag name in the config file to define properties to be initialized in the component
    /// </summary>
    public const string TAGNAME_PROPERTIES = "properties";
    /// <summary>
    /// Tag name in the config file to define the constructor to be used to initialize the component
    /// </summary>
    public const string TAGNAME_CONSTRUCTOR = "constructor";
    /// <summary>
    /// Tag name in the component config file that identifies the remoting properties
    /// </summary>
    public const string TAGNAME_REMOTING = "remoting";
    /// <summary>
    /// Tag name in the component config file that identifies the component remoting mode
    /// </summary>
    public const string TAGNAME_REMOTING_OBJECTMODE = "objectMode";
    /// <summary>
    /// Tag name in the component config file that identifies a factory to be used for initialization
    /// </summary>
    public const string TAGNAME_FACTORY = "factory";
    /// <summary>
    /// Tag name in the component config file that identifies a factory method to be used for initialization
    /// </summary>
    public const string TAGNAME_METHOD = "method";
    /// <summary>
    /// Creates a new empty configuration
    /// </summary>
    public ComponentConfiguration()
		{			
		}
    private ClassAssemblyPair mType;
    private ComponentInitializerCollection mMethods;
    private ComponentInitializerCollection mProperties;
    private ComponentInitializerCollection mConstructorArguments;
    private RemotingComponentConfiguration mRemoting;
    private ComponentInitializationFactory mFactory;

    //private string mScope;
    /// <summary>
    /// The type of the component
    /// </summary>
    /// <value></value>
    public ClassAssemblyPair ComponentType
    {
      get { return mType; }
      set { mType = value; }
    }
    /// <summary>
    /// Accessor for the method definitions
    /// </summary>
    /// <value>The ComponentInitializer the defines the name of the method and the value to parse</value>
    public ComponentInitializerCollection Methods
    {
      get { return mMethods; }
    }
    /// <summary>
    /// Add a method definition to the list
    /// </summary>
    /// <param name="p">The ComponentInitializer the defines the name of the method and the value to parse</param>
    public void AddMethod(ComponentInitializer p)
    {
      if (mMethods == null) mMethods = new ComponentInitializerCollection();
      mMethods.Add(p);
    }
    /// <summary>
    /// Accessor for the properties definitions
    /// </summary>
    /// <value>The ComponentInitializer the defines the name of the property and the value to parse</value>
    public ComponentInitializerCollection Properties
    {
      get { return mProperties; }
    }
    /// <summary>
    /// Add a property definition to the list
    /// </summary>
    /// <param name="p">The ComponentInitializer the defines the name of the property and the value to parse</param>
    public void AddProperty(ComponentInitializer p)
    {
      if (mProperties == null) mProperties = new ComponentInitializerCollection();
      mProperties.Add(p);
    }
    /// <summary>
    /// Accessor for the argument definitions of the constructor to use
    /// </summary>
    /// <value>The ComponentInitializer the defines the name of the arguments of the constructor to use and the value to parse</value>
    public ComponentInitializerCollection ConstructorArguments
    {
      get { return mConstructorArguments; }
    }
    /// <summary>
    /// Add an argument definition of the constructor to use to the list
    /// </summary>
    /// <param name="p">The component initializer the defines the name of the arguments of the constructor to use and the value to parse</param>
    public void AddConstructorArgument(ComponentInitializer p)
    {
      if (mConstructorArguments == null) mConstructorArguments = new ComponentInitializerCollection();
      mConstructorArguments.Add(p);
    }
    /// <summary>
    /// Remoting properties
    /// </summary>
    public RemotingComponentConfiguration Remoting
    {
      get { return mRemoting; }
      set { mRemoting = value; }
    }
    /// <summary>
    /// Factory definition to use for initialization
    /// </summary>
    public ComponentInitializationFactory Factory
    {
      get { return mFactory; }
      set { mFactory = value; }
    }
  }
}
